from typing import List


# 用时：22.18%   内存：26.20%
class Solution:

    def medianSlidingWindow(self, nums: List[int], k: int) -> List[float]:
        result = []
        for i in range(len(nums)-k+1):
            result.append(self.median(nums[i: i+k]))
        return result

    def median(self, data):
        data.sort()
        half = len(data) // 2
        return (data[half] + data[~half])/2


nums = [1,3,-1,-3,5,3,6,7]
k = 3
model = Solution()
result = model.medianSlidingWindow(nums, k)
print(result)